export class CancellationToken {
    constructor(private readonly promise: Promise<void>) { }

    get IsCancellationRequested(): boolean {
        return !!(this.promise && (this.promise as any)._canceled);
    }

    ThrowIfCancellationRequested(): void {
        if (this.IsCancellationRequested) {
            throw new Error('The operation was canceled.');
        }
    }
}
